package com.onec.service.im.codec;

import com.onec.service.im.protocol.Common;
import io.netty.buffer.ByteBuf;
import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.MessageToByteEncoder;

public class ProtoEncode extends MessageToByteEncoder<Common.Point> {
    @Override
    protected void encode(ChannelHandlerContext ctx, Common.Point msg, ByteBuf out) throws Exception {
        byte[] bytes = msg.toByteArray();
        int length = bytes.length;

        out.writeShort(length);
        // 写入魔数 版本号等
        // 写入消息提
        out.writeBytes(bytes);
    }
}
